//
//  ScenicIntroductioncell.m
//  IMTourist
//
//  Created by 王鹏宇 on 2017/4/6.
//  Copyright © 2017年 王鹏宇. All rights reserved.
//

#import "ScenicIntroductioncell.h"

@interface ScenicIntroductioncell()
@property (weak, nonatomic) IBOutlet UILabel *ScenicNameLabel;

@property (weak, nonatomic) IBOutlet UILabel *timeLabel;

@property (weak, nonatomic) IBOutlet UILabel *distanceLabel;

@property (weak, nonatomic) IBOutlet UILabel *guiderNumLabel;

@property (weak, nonatomic) IBOutlet UILabel *visitCountLabel;

@property (weak, nonatomic) IBOutlet UIImageView *ScenicImageView;


@end

@implementation ScenicIntroductioncell

- (void)awakeFromNib {
    [super awakeFromNib];
    [IGUtils viewShowShadow:self.contentView shadowRadius:5 shadowOpacity:0.5 WithColor:[UIColor blackColor]];
    self.ScenicNameLabel.textColor = kTitleColor;
    self.timeLabel.textColor = kContentColor;
    self.visitCountLabel.textColor = kContentColor;
    self.guiderNumLabel.textColor = kContentColor;
    self.distanceLabel.textColor = kContentColor;
}
-(void)setFrame:(CGRect)frame
{
    frame.origin.x = 15;//这里间距为10，可以根据自己的情况调整
    frame.size.width -= 2 * frame.origin.x;
    frame.size.height -= frame.origin.x;
    [super setFrame:frame];
}

- (void)configScenicWith:(Scenic *)scenic {
    CGFloat distance = [IGUtils getDistanceFromCoordinate:CLLocationCoordinate2DMake(scenic.lat.floatValue, scenic.lng.floatValue) toCoordinate:[LocationManager sharedManager].currentLocation.coordinate];
    distance = distance / 1000.0f;
    
    self.ScenicNameLabel.text = scenic.viewname;
    self.timeLabel.text = scenic.openinfo;
    if (distance >= 10) {
       self.distanceLabel.text = @">10 km";
    }else if(distance < 0.1){
        self.distanceLabel.text = @"<100m";
    }else{
        self.distanceLabel.text = [NSString stringWithFormat:@"%0.2f km",distance];
    }
    
    self.guiderNumLabel.text = [NSString stringWithFormat:@"%@",scenic.guides];
    self.visitCountLabel.text = [NSString stringWithFormat:@"%@",scenic.visit];
    [self.ScenicImageView setImageURL:[NSURL URLWithString:[scenic.pictureArray firstObject]] placeholderImage:[UIImage imageNamed:@"placeholder_squ"]];
    
}


- (void)congfigLineWith:(LineModel *)model {
    
//    CGFloat distance = [IGUtils getDistanceFromCoordinate:CLLocationCoordinate2DMake(model.lat.floatValue, model.lng.floatValue) toCoordinate:[LocationManager sharedManager].currentLocation.coordinate];
//    distance = distance / 1000.0f;
//    
//    self.ScenicNameLabel.text = model.linename;
//    self.timeLabel.text = [model.timelabel stringValue];
//    if (distance >= 10) {
//        self.distanceLabel.text = @"≥10 km";
//    }else if(distance < 0.1){
//        self.distanceLabel.text = @"<100 m";
//    }else{
//        self.distanceLabel.text = [NSString stringWithFormat:@"%0.2f km",distance];
//    }
    
    self.guiderNumLabel.text = [NSString stringWithFormat:@"%ld",random()%20];
    self.visitCountLabel.text = [NSString stringWithFormat:@"%@",model.visits];
    [self.ScenicImageView setImageURL:[NSURL URLWithString:model.pictures] placeholderImage:[UIImage imageNamed:@"placeholder_squ"]];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
